
function myAjax(url, data, type) {
    let result = null;
    // data.loginName = sessionStorage.getItem("loginName");
    let login = {loginName: sessionStorage.getItem("loginName")};
    $.ajax({
        url: url,//地址：访问后台的地址
        data:  Object.assign(data, login),//前端传递给后台的数据
        type: type,
        async: false,
        dataType: 'json',//是后端传递到前端的数据格式
        xhrFields:{
            withCredentials:true
        },
        beforeSend: function(xhr) {
            let token = localStorage.getItem("token")
            xhr.setRequestHeader("Authorization", token);
        },
        success: function (ev) {//后端给前端的一个反馈
            if (sessionStorage.getItem("loginName") == null || ev.code === 4) {
                location.href = '/login.html'
                return false
            }
            result=ev
        }
    });
    return result
}